
cd ""  /*write the path to WVS, wave six here*/

	*WVS wave 6 can be found at http://www.worldvaluessurvey.org/WVSDocumentationWV6.jsp
use WV6_short.dta, clear

*V2= country
*v84= interested in politics (P)
*v85-89= other ways to participate like signing a petition (P)
*v25-v35= organization membership (M)
*v227 do you usually vote? (V)
*v24 most people can be trusted; no question on politicians can be trusted, which was included in our own survey (T)
*V248= EDUCATION
*V242= AGE
*V240= GENDER
*V238= SES



		*recode v227 to change direction of variable
		recode V227 (2=4)
		recode V227 (1=5)
			replace V227=. if V227!=3&V227!=4&V227!=5 /*this takes care of the negative values, which are missing values in WVS*/
				*final score 3=never; 4=usually; 5=always

		foreach i of varlist V25-V35 {
		replace `i'=. if `i'<0
		}
			*the line above gets rid of negative values, which are missing
			*final score 0=dont belong; 1= inactive member; 2=active member
			
		foreach j of varlist V85-V89 {
		replace `j'=4 if `j'==2
		replace `j'=5 if `j'==1
		replace `j'=. if `j'<0
		}
		*line above changes the direction of variable+ gets rid of negative values
			*final score 3=would never do; 4=might do; 5=have done
			
		recode V84 (3=5) (2=6) (1=7) /*change the direction of variable*/
		replace V84=. if V84<0 /*negative values in WVS are missing values */
			*final score 4=not at all interested; 5=not very interested; 6=somewhat interested; 7=very intersted
		
		recode V24 (1=3) /*change direction of variable*/
		replace V24=. if V24<0 /*negative values in WVS are missing values */
			*final score 2=need to be careful; 3= most people can be trusted
			
		replace V248=. if V248<0 /*negative values in WVS are missing values */
		gen university=.
		replace university=0 if V248<9
		replace university=1 if V248==9
		
		foreach i of varlist V242 V240 V238 {
		replace `i' =. if `i'<0
		} /*negative values coded as missing */
	
		
		***STANDARDIZE EACH OF THE INDIVIDUAL VARIABLES
		
		foreach i of varlist V227 V25-V35 V85-V89 V84 V24 {
		egen m_`i'=mean(`i')
		egen sd_`i'=sd(`i')
		gen `i'_2=(`i'-m_`i')/sd_`i'
		}
		
		
		**CREATE AVERAGE FOR POLITICS and MEMBERSHIP IN ORGANIZATIONS
		gen pol_avg=(V84_2+V85_2+V86_2+V87_2+V88_2+V89_2+V29_2)/7
		gen membership_avg=(V26_2+V27_2+V28_2+V30_2+V31_2+V32_2+V33_2+V34_2+V35_2)/10
		
		*GEN UNSTANDARDIZED SCORE
		gen social_capital=(pol_avg+membership_avg+V227_2+V24_2)/4
		
		*GEN FINAL STANDARDIZED SCORE
		qui egen m_social_capital=mean(social_capital)
		qui egen sd_social_capital=sd(social_capital)
		gen social_capital2=(social_capital-m_social_capital)/sd_social_capital
		

	
		*gen a string variable with name of country
	
	decode V2, gen(country)
		*the countries with names made of more than one word need changed, so that we can use the names in the code below
	replace country="United_States" if country=="United States"
	replace country="South_Africa" if country=="South Africa"
	replace country="South_Korea" if country=="South Korea"
	replace country="Hong_Kong" if country=="Hong Kong"
	replace country="New_Zealand" if country=="New Zealand"
	replace country="Trinidad_and_Tobago" if country=="Trinidad and Tobago"
	replace country="United_States" if country=="United States"
	replace country="ROMANIA" if country=="Romania"
	
	local country Lebanon Haiti Jordan Algeria Thailand Kyrgyzstan Malaysia Libya Iraq Kazakhstan ///
			India Philippines Ukraine Georgia Russia Turkey Cyprus Argentina Armenia Tunisia Egypt ///
			ROMANIA Japan Rwanda Peru Nigeria China Azerbaijan Yemen Pakistan Chile Zimbabwe Australia Palestine ///
			Ghana Poland Estonia Slovenia Sweden Mexico Brazil Uruguay ///
			Netherlands Colombia 
	
	*next are regressions by each individual country; results are stored and will be graphed later
	
	foreach x of local country {
	
	gen `x'=university
	quietly regress social_capital2 `x' if country=="`x'"&V229!=6 /*the last condition (V229!=6) gets rid of those who are still in university
																	as we are only interested in those who graduated*/
	estimates store `x'
	}
	
	**The countries made of more than one word will be done separately, to add labels to the variables created
	*these labels are the real names of the countries and will appear on the graph
	gen United_States=university
	label variable United_States "United States"
	quietly regress social_capital2 United_States if country=="United_States"&V229!=6
	estimates store United_States
	
	gen South_Africa=university
	label variable South_Africa "South Africa"
	quietly regress social_capital2 South_Africa if country=="South_Africa"&V229!=6
	estimates store South_Africa

	gen South_Korea=university
	label variable South_Korea "South Korea"
	quietly regress social_capital2 South_Korea if country=="South_Korea"&V229!=6
	estimates store South_Korea
	
	gen Hong_Kong=university
	label variable Hong_Kong "Hong Kong"
	quietly regress social_capital2 Hong_Kong if country=="Hong_Kong"&V229!=6
	estimates store Hong_Kong
	
	gen New_Zealand=university
	label variable New_Zealand "New Zealand"
	quietly regress social_capital2 New_Zealand if country=="New_Zealand"&V229!=6
	estimates store New_Zealand	
	
	gen Trinidad_and_Tobago=university
	label variable Trinidad_and_Tobago "Trinidad and Tobago"
	quietly regress social_capital2 Trinidad_and_Tobago if country=="Trinidad_and_Tobago"&V229!=6
	estimates store Trinidad_and_Tobago	
	
	***CREATE FIGURE 6
	
	ssc install coefplot
	
	coefplot (United_States, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Colombia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Netherlands, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Uruguay, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Brazil, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Trinidad_and_Tobago, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(New_Zealand, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Mexico, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Sweden, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Slovenia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Estonia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Poland, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Hong_Kong, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Ghana, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Palestine, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Australia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Zimbabwe, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Chile, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Pakistan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Yemen, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Azerbaijan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (China, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Nigeria, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Peru, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Rwanda, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Japan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(ROMANIA, mcolor(black) msymbol(square) msize(vsmall) ciopts(lcolor(black))) (Egypt, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Tunisia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Armenia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Argentina, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Cyprus, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(South_Korea, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Turkey, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Russia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Georgia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Ukraine, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Philippines, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(India, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Kazakhstan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Iraq, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Libya, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Malaysia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Kyrgyzstan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Thailand, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (South_Africa, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Algeria, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Jordan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
	(Haiti, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Lebanon, mcolor(black) msize(vsmall) ciopts(lcolor(black))), ///
	drop(_cons) legend(off) graphregion(color(white)) yscale(alt) xlabel(,labsize(tiny)) ylabel(,labsize(tiny)) ///
	aspectratio(2.5) xline(0, lcolor(black))

	
	graph export figure7.pdf, replace
	
	
	****SAME FIGURE BUT WITH CONTROLS FOR GENDER, SES AND AGE for Appendix
	
	estimates clear
	
	foreach x of local country {
	
	quietly regress social_capital2 `x' V242 V240 V238 ///
	if country=="`x'"&V229!=6 /*the last condition (V229!=6) gets rid of those who are still in university
																	as we are only interested in those who graduated*/
	estimates store `x'
	}
	
	**The countries made of more than one word will be done separately, to add labels to the variables created
	*these labels are the real names of the countries and will appear on the graph

	quietly regress social_capital2 United_States V242 V240 V238 if country=="United_States"&V229!=6
	estimates store United_States
	

	quietly regress social_capital2 South_Africa V242 V240 V238 if country=="South_Africa"&V229!=6
	estimates store South_Africa


	quietly regress social_capital2 South_Korea V242 V240 V238 if country=="South_Korea"&V229!=6
	estimates store South_Korea
	

	quietly regress social_capital2 Hong_Kong V242 V240 V238 if country=="Hong_Kong"&V229!=6
	estimates store Hong_Kong
	

	quietly regress social_capital2 New_Zealand V242 V240 V238 if country=="New_Zealand"&V229!=6
	estimates store New_Zealand	
	
	quietly regress social_capital2 Trinidad_and_Tobago V242 V240 V238 if country=="Trinidad_and_Tobago"&V229!=6
	estimates store Trinidad_and_Tobago	
	
	***CREATE FIGURE 
	
	ssc install coefplot
	
	coefplot (Colombia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (United_States, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Brazil, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Mexico, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Trinidad_and_Tobago, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Slovenia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(New_Zealand, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Uruguay, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Sweden, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Netherlands, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Ghana, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Yemen, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Chile, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Poland, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Australia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Pakistan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Zimbabwe, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Peru, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Hong_Kong, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Estonia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Palestine, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Japan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(China, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Cyprus, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Azerbaijan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (ROMANIA, mcolor(black) msymbol(square) msize(vsmall) ciopts(lcolor(black))) ///
			(Tunisia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Argentina, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Armenia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Ukraine, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Egypt, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (South_Korea, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Russia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Georgia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Rwanda, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Turkey, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Kazakhstan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Malaysia, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Philippines, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Nigeria, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Jordan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Kyrgyzstan, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Haiti, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Libya, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(South_Africa, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Iraq, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(Algeria, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Thailand, mcolor(black) msize(vsmall) ciopts(lcolor(black))) ///
			(India, mcolor(black) msize(vsmall) ciopts(lcolor(black))) (Lebanon, mcolor(black) msize(vsmall) ciopts(lcolor(black))), ///
			drop(_cons V242 V240 V238) legend(off) graphregion(color(white)) yscale(alt) xlabel(,labsize(tiny)) ylabel(,labsize(tiny)) ///
			aspectratio(2.5) xline(0, lcolor(black))

		graph export figure_D1_appendix.pdf, replace
